package sketch.generator.examples;

import sketch.generator.ChainValueGenerator;
import sketch.util.SketchUtil;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

public class SequentialValueGeneratorTest extends TestCase {
	
	public static Test suite() {
        return new TestSuite(SequentialValueGeneratorTest.class);
    }
	

	@SuppressWarnings("unchecked")
	public void testSingleValueGenerator() {
		SketchUtil.stdln("Executing testSingleValueGenerator");
		ChainValueGenerator<String> chainString1 = new ChainValueGenerator<String>();
		chainString1.add(new String[]{"string 1", "string 2", "string 3"});
		ChainValueGenerator<String> chainString2 = new ChainValueGenerator<String>();
		chainString2.add(new String[]{"string 4", "string 5", "string 6"});
		ChainValueGenerator<String> chainString3 = new ChainValueGenerator<String>();
		chainString3.add(new String[]{"string 7", "string 8", "string 9"});
		ChainValueGenerator<String> chainString4 = new ChainValueGenerator<String>();
		chainString4.add(new String[]{"string 10", "string 11", "string 12"});
		ChainValueGenerator<String> chainString5 = new ChainValueGenerator<String>();
		chainString5.add(new String[]{"string 13", "string 14", "string 15"});
		
		while(chainString1.hasNext()) {
			SketchUtil.stdln(chainString1.next());
		}
		
		while(chainString2.hasNext()) {
			SketchUtil.stdln(chainString2.next());
		}
		
		chainString1.reset();
		chainString2.reset();
		
		PermutationSequentialValueGenerator<String> generator
		    = new PermutationSequentialValueGenerator<String>(chainString1, chainString2, chainString3, chainString4, chainString5);
		
		int num = 0;
		while(generator.hasNext()) {
			SketchUtil.stdln("Generating " + (++num) + "th value: ");
			SequentialValue<String> sequentialValue = generator.next();
			SketchUtil.stdln(sequentialValue.toString());
			SketchUtil.stdln();
			//List<String> strs = sequentialValue.getValues();
		}
		
		assertTrue(num == 243);
	}
}
